package com.example.pilipili.controller;


import com.example.pilipili.common.R;
import com.example.pilipili.pojo.entity.Collection;
import com.example.pilipili.pojo.entity.Follow;
import com.example.pilipili.pojo.entity.Like;
import com.example.pilipili.service.CollectionService;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author liyv
 * @since 2023-12-01
 */
@RestController
@RequestMapping("/collection")
public class CollectionController {

    @Autowired
    CollectionService collectionService ;

    /**
     * 点击收藏按钮
     * @param collection uid,vid
     * @return collection
     */
    @PostMapping
    public R<Collection> addLike(@RequestBody @Valid Collection collection){
        return collectionService.click(collection) ;
    }

    /**
     * 某用户对某视频 是否收藏
     * @param collection uid ， vid
     * @return boolean
     */
    @PostMapping("/init")
    public R getInitForU(@RequestBody @Valid  Collection collection){
        return R.ok(collectionService.isCollection(collection.getUid(),collection.getVid())) ;
    }



}

